using System;
using System.Web.UI;

using DotNetNuke;
using DotNetNuke.Entities.Modules;
using DotNetNuke.Services.Exceptions;
using DotNetNuke.Services.Localization;

using Jfc.DnnMarketingTools.MemberInvite;

namespace Jfc.DnnMarketingTools.MemberInvite
{
    /// -----------------------------------------------------------------------------
    /// <summary>
    /// The Settings class manages Module Settings
    /// </summary>
    /// <remarks>
    /// </remarks>
    /// <history>
    /// </history>
    /// -----------------------------------------------------------------------------
    partial class StatusControl : UserControl
    {
        const string LocalFile = "~/DesktopModules/MemberInvite/App_LocalResources/StatusControl.ascx";

        public StatusType Status
        {
            get
            {
                object o = ViewState["Status"];
                return (o == null) ? StatusType.Registered : (StatusType)o;
            }
            set
            {
                ViewState["Status"] = value;
            }
        }

        //private DateTime _StatusDate = DateTime.MinValue;

        public DateTime StatusDate
        {
            get
            {
                object o = ViewState["StatusDate"];
                return (o == null) ? DateTime.MinValue : (DateTime)o;
            }
            set
            {
                ViewState["StatusDate"] = value;
            }
        }


        #region Base Method Implementations

        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (Page.IsPostBack == false)
                {
                    string statusText = Localization.GetString("lblStatus_Prefix.Text", LocalFile);
                    statusText += " ";
                    statusText += Status.ToString(); // TODO: Status.ToString()
                    statusText += " ";
                    statusText += Localization.GetString("lblStatus_Separator.Text", LocalFile);
                    statusText += " ";
                    statusText += StatusDate.ToString();

                    lblStatus.Text = statusText;
                }
            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }

        #endregion

    }
}


